package toolCode

import (
	"regexp"
)

func Delete_note(str string) string {
	return removeAllComments(str)
}

// removeComments 移除单行注释
func removeComments(line string) string {
	// 移除单行注释
	re := regexp.MustCompile(`//.*`)
	line = re.ReplaceAllString(line, "")
	return line
}

// removeMultiLineComments 移除多行注释
func removeMultiLineComments(text string) string {
	// 移除多行注释
	re := regexp.MustCompile(`/\*[\s\S]*?\*/`)
	text = re.ReplaceAllString(text, "")
	return text
}

// removeComments 移除所有类型的注释
func removeAllComments(text string) string {
	// 移除多行注释
	reMultiLine := regexp.MustCompile(`/\*[\s\S]*?\*/`)
	text = reMultiLine.ReplaceAllString(text, "")

	// 移除单行注释
	reSingleLine := regexp.MustCompile(`//.*`)
	text = reSingleLine.ReplaceAllString(text, "")

	return text
}
